package com.ruoyi.project.system.info.controller;

import java.util.List;

import com.ruoyi.common.utils.PageQuery;
import com.ruoyi.framework.web.page.TableData;
import com.ruoyi.project.system.kind.domain.InfoKind;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.info.domain.Info;
import com.ruoyi.project.system.info.service.IInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * webController
 * 
 * @author ruoyi
 * @date 2024-07-12
 */
@Controller
@RequestMapping("/system/info")
public class InfoController extends BaseController
{
    private String prefix = "system/info";

    @Autowired
    private IInfoService infoService;

    @GetMapping()
    public String info()
    {
        return prefix + "/info";
    }

    /**
     * 查询web列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableData<Info> list(Info info, PageQuery pageQuery)
    {
        return infoService.selectInfoList(info, pageQuery);
    }

    /**
     * 新增web
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存web
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Info info)
    {
        return toAjax(infoService.insertInfo(info));
    }

    /**
     * 修改web
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Info info = infoService.selectInfoById(id);
        mmap.put("info", info);
        return prefix + "/edit";
    }

    /**
     * 修改保存web
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Info info)
    {
        return toAjax(infoService.updateInfo(info));
    }

    /**
     * 删除web
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(infoService.deleteInfoByIds(ids));
    }
}
